<link  href="/layer/mobile/need/layer.css " rel="stylesheet">
<!--采用模块化方式-->

<!-- jQuery (necessary JavaScript plugins) -->
<script type='text/javascript' src="/js/lib/jquery-2.2.1.js"></script>
<script src="/layer/layer.js"></script>
<style>
#select2 {
    width: 300px;
    height: 20px;
    line-height: 20px;
}
#select2 option{
    display: inline-block;
    margin: 0 20px;
}
</style>
<form id="upload-form" action="/excel/import" method="post" enctype="multipart/form-data">
    <input type="hidden" name="_token" value="{{csrf_token()}}">
    <div class="file-loading">
        <input id="uploadFile" name="file" type="file">
    </div>

    <label>选择适用班级：</label>
    <select  id="select2" name="classes[]" multiple="multiple" data-placeholder="选择班级">

    </select>
    <button type="submit">提交</button>
</form>
<script>
   $(function(){
     let $classes = [];
       layer.open({
           id: 'son',
           type: 2,
           area: ["45%", "35%"],
           title: "班级选择",
           //maxmin: true, //开启最大化最小化按钮
           btnAlign: 'c',
           content:['/excel/fields'],
           btn: ["确定","关闭"],
           yes:function(layero, index){
               var newpsw = window[index.find('iframe')[0]['name']];
              $classes = newpsw.getChoseId();
               appendOption($classes);
               layer.close(layer.index);

               // var i = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
               // parent.layer.close(i)

           },
           btn1: function(layer,index){},
           cancel: function (index, layer) {

           },
           success: function(dom){
               let $iframeDom=$(dom[0]).find("iframe").eq(0).contents();
               let Ids =$iframeDom.find(".bb").html();
               //console.log(Ids);
           }
       });

      function appendOption($dom_arr) {
          $.each($dom_arr,function ($k,$v) {
              var $option = `<option class="remove_option" value="${$v.id}">${$v.html}<span class="add-dom-close-btn">x</span></option>`;
              $('#select2').append($option);
          });
      }
   });
    $("#select2").on('click','.remove_option',function (e) {
        let index = $(this).index();
        $('#select2 > .remove_option').eq(index).remove();
    })
</script>